package 基础题;

import java.util.*;

/**
 *
 * @author : CHZERO
 * @date   : 2019-03-21 10:25:23
 * @email  : 827348260@qq.com
 * @description :  通过TreeMap 实现词频统计. 词为key, 出现次数为value. 首次出现插入1, 重复出现+1
 */
public class HDU1004 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		List<String> list = new ArrayList<>();
		while (scanner.hasNext()) {
			int count = scanner.nextInt();
			if (count == 0) { break; }
			Map<String, Integer> map = new TreeMap<>();
			for (int i = 0; i < count; i++) {
				String color = scanner.next();
				map.merge(color, 1, (a, b) -> a + b);
			}
			Map.Entry<String, Integer> maxEntry = null;
			for (Map.Entry<String, Integer> entryItem : map.entrySet()) {
				if (maxEntry == null) {
					maxEntry = entryItem;
					continue;
				}
				if (maxEntry.getValue().compareTo(entryItem.getValue()) < 0) {
					maxEntry = entryItem;
				}
			}
			list.add(maxEntry.getKey());
		}
		for (String key: list){
			System.out.println(key);
		}
	}

}
